const http=require('http');
const url=require('url');

http.createServer((request,response)=>{

    /**
     * 跨域问题
     */
    response.setHeader('Access-Control-Allow-Origin','*');
    response.setHeader('Access-Control-Allow-Methods','POST, GET, OPTIONS, DELETE')
    response.setHeader('Access-Control-Allow-Headers','content-type,x-requested-with,Authorization,x-ui-request,lang,accept,access-control-allow-origin')
    response.setHeader('Access-Control-Allow-Credentials','true')

    const urlObj = url.parse(request.url,true);
    console.log(urlObj)
    const responseMessage={
        flag:false
    }

    if(urlObj.pathname=='/1.getHttp'){
        const getUser = urlObj.query();

        if (getUser.username == 'admin'){
            responseMessage.flag=true
        }
        response.end(JSON.stringify(responseMessage))
    }

    response.end();

}).listen(3000,()=>{
    console.log("3000")
})
